package dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import dao.utils.GenericHibernateDAO;
import domain.LineaCompra;
import domain.LineaVenta;

public class LineaVentaDAOImpl extends GenericHibernateDAO implements LineaVentaDAO {

	public LineaVentaDAOImpl(Session s) {
		super(s);
	}
	
	public List<LineaVenta> findAll(){
		Query q=getSession().createQuery("From LineaVenta as lventa");
		return q.list();
	}

	@Override
	public List<LineaVenta> findById(int id) {
		// TODO Auto-generated method stub
		Query q = getSession().createQuery("From LineaVenta where ID_VENTA_LV = ?").setInteger(0, id);
		return q.list();
	}

	public boolean saveLV(LineaVenta lv) {
		try {
			getSession().save(lv);
			return true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
			return false;
		}
	}
}